package com.cq.controller;

import com.cq.pojo.User;
import com.cq.service.EmployeeService;
import com.cq.service.StuService;
import com.cq.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/student/normal")
public class DeleteController {

    @Autowired
    private UserService userService;

    @Autowired
    private EmployeeService employeeService;

    @Autowired
    private StuService stuService;

    @RequestMapping("/deleteAdminView")
    public String deleteAdminView(){
        return "delete/deleteAdmin";
    }

    @RequestMapping("/deleteAdmin")
    public String deleteAdmin(String UserId){
        int result = userService.deleteUser(UserId);
        if(result>0){
            System.out.println("删除成功");
        }
        return "redirect:/student/normal/queryAllUser";
    }

    @RequestMapping("/deleteStuView")
    public String deleteStuView(){
        return "delete/deleteStu";
    }

    @RequestMapping("/deleteStu")
    public String deleteStu(int Stu_Key){
        int result = userService.deleteOneStu(Stu_Key);
        if(result>0){
            System.out.println("删除成功");
        }
        return "redirect:/student/normal/queryAllStu";
    }

    @RequestMapping("/deleteEmpView")
    public String deleteEmpView(){
        return "delete/deleteEmp";
    }

    @RequestMapping("/deleteEmp")
    public String deleteEmp(String Emp_Id){
        int result = userService.deleteOneEmp(Emp_Id);
        if(result>0){
            System.out.println("删除成功");
        }
        return "redirect:/student/normal/queryAllEmp";
    }
}
